#include "interrupt.h"
#include "gic.h"
#include "tick.h"
#include <stdint.h>
#include "uart.h"
extern void gic_irq_handler(void);
extern void exception_handler(uint32_t sp);
extern int cp15_tick_handler(void);
void gic_irq_handler(void)
{
    uint32_t irq = gic_acknowledge_irq();
    
     gic_disable_irq(irq);
    if(irq == 29){
        cp15_tick_handler();
    }else{

    }
    gic_end_of_irq(irq);
    gic_enable_irq(irq);
}

void exception_handler(uint32_t sp)
{
    uint32_t* exception =(uint32_t*)sp; 
    printf("cpsr 0x%x\n",*exception ++);
    printf("r0 0x%x\n",*exception ++);
    printf("r1 0x%x\n",*exception ++);
    printf("r2 0x%x\n",*exception ++);
    printf("r3 0x%x\n",*exception ++);
    printf("r4 0x%x\n",*exception ++);
    printf("r5 0x%x\n",*exception ++);
    printf("r6 0x%x\n",*exception ++);
    printf("r7 0x%x\n",*exception ++);
    printf("r8 0x%x\n",*exception ++);
    printf("r9 0x%x\n",*exception ++);
    printf("r10 0x%x\n",*exception ++);
    printf("r11 0x%x\n",*exception ++);
    printf("r12 0x%x\n",*exception ++);
    printf("lr 0x%x\n",*exception ++);
    while(1);
}


